import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _isEmpty from "lodash/isEmpty";
var _excluded = ["id", "userOrganizationId", "antherPassword"];
import { createPagination, getResponse } from 'utils/utils';
import { queryMapIdpValue, queryUnifyIdpValue, getPublicKey as _getPublicKey } from 'cpaas-front/lib/services/api'; // 相对路径

import { addUserGroup as _addUserGroup, apiFieldApiQuery, apiFieldFieldPermissionCreate, apiFieldFieldPermissionQuery, apiFieldFieldPermissionRemove, apiFieldFieldPermissionUpdate, deleteRoles as _deleteRoles, deleteUserGroup as _deleteUserGroup, querySubAccountOrgList, queryUnitsTree as _queryUnitsTree, subAccountOrgCreateOne, subAccountOrgGroupCurrent, subAccountOrgGroupQueryAll, subAccountOrgQuery, subAccountOrgRoleCurrent, subAccountOrgRoleQueryAll, subAccountOrgUpdateOne, subAccountOrgUpdatePassword, subAccountSiteUserUnlock, queryAssignableSecGrp, queryFieldPermission as _queryFieldPermission, queryDataDimension as _queryDataDimension, querySecurityGroup as _querySecurityGroup, queryFieldConfig as _queryFieldConfig, assignSecGrp as _assignSecGrp, deleteSecGrp as _deleteSecGrp, queryTabList, queryDimension as _queryDimension, queryEmployee as _queryEmployee } from "../services/subAccountOrgService";
import { getPasswordRule as _getPasswordRule } from "../services/commonService"; // import uuid from 'uuid/v4';

export default {
  namespace: 'subAccountOrg',
  state: {
    enumMap: {},
    // 可分配角色
    createSubRoles: [],
    dataSource: [],
    pagination: {},
    // 分页信息
    editFormProps: {},
    editModalProps: {},
    passwordProps: {},
    // 组织树
    unitsTree: [],
    requestMethod: [],
    // 请求方式
    fieldType: [],
    // 字段类型
    apiDataSource: [],
    // 接口数据源
    apiPagination: {},
    // 接口分页
    fieldPermissionDataSource: [],
    // 字段权限数据源
    fieldPermissionPagination: {},
    // 字段权限分页
    passwordTipMsg: {},
    publicKey: '',
    // 公钥
    secGrpList: [],
    // 安全组列表
    secGrpPagination: {},
    // 安全组分页
    secGrpAddModalList: [],
    // 可分配安全组列表
    secGrpAddModalPagination: {},
    // 可分配安全组分页
    secGrpFieldPermissionList: [],
    // 安全组字段权限列表
    secGrpFieldPermissionPagination: {},
    // 安全组字段权限分页
    secGrpDimensionList: [],
    // 安全组数据权限维度列表
    secGrpDimensionPagination: {},
    // 安全组数据权限维度分页
    secGrpDataPermissionTabList: [],
    // 安全组数据权限tab页
    dimensionList: [],
    employeePagination: {},
    employeeList: []
  },
  effects: {
    fetchList: /*#__PURE__*/_regeneratorRuntime.mark(function fetchList(_ref, _ref2) {
      var payload, call, put, res;
      return _regeneratorRuntime.wrap(function fetchList$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              payload = _ref.payload;
              call = _ref2.call, put = _ref2.put;
              _context.t0 = getResponse;
              _context.next = 5;
              return call(querySubAccountOrgList, payload);

            case 5:
              _context.t1 = _context.sent;
              res = (0, _context.t0)(_context.t1);

              if (_isEmpty(res)) {
                _context.next = 10;
                break;
              }

              _context.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  dataSource: res.content,
                  pagination: createPagination(res)
                }
              });

            case 10:
            case "end":
              return _context.stop();
          }
        }
      }, fetchList);
    }),
    getPublicKey: /*#__PURE__*/_regeneratorRuntime.mark(function getPublicKey(_, _ref3) {
      var call, put, res;
      return _regeneratorRuntime.wrap(function getPublicKey$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              call = _ref3.call, put = _ref3.put;
              _context2.next = 3;
              return call(_getPublicKey);

            case 3:
              res = _context2.sent;

              if (!res) {
                _context2.next = 7;
                break;
              }

              _context2.next = 7;
              return put({
                type: 'updateState',
                payload: {
                  publicKey: res.publicKey
                }
              });

            case 7:
              return _context2.abrupt("return", res);

            case 8:
            case "end":
              return _context2.stop();
          }
        }
      }, getPublicKey);
    }),
    // 获取密码校验规则
    getPasswordRule: /*#__PURE__*/_regeneratorRuntime.mark(function getPasswordRule(_ref4, _ref5) {
      var payload, call, put, res;
      return _regeneratorRuntime.wrap(function getPasswordRule$(_context3) {
        while (1) {
          switch (_context3.prev = _context3.next) {
            case 0:
              payload = _ref4.payload;
              call = _ref5.call, put = _ref5.put;
              _context3.t0 = getResponse;
              _context3.next = 5;
              return call(_getPasswordRule, payload);

            case 5:
              _context3.t1 = _context3.sent;
              res = (0, _context3.t0)(_context3.t1);

              if (!res) {
                _context3.next = 10;
                break;
              }

              _context3.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  passwordTipMsg: res
                }
              });

            case 10:
              return _context3.abrupt("return", res);

            case 11:
            case "end":
              return _context3.stop();
          }
        }
      }, getPasswordRule);
    }),
    fetchDetail: /*#__PURE__*/_regeneratorRuntime.mark(function fetchDetail(_ref6, _ref7) {
      var payload, call, subAccountDetail;
      return _regeneratorRuntime.wrap(function fetchDetail$(_context4) {
        while (1) {
          switch (_context4.prev = _context4.next) {
            case 0:
              payload = _ref6.payload;
              call = _ref7.call;
              _context4.next = 4;
              return call(subAccountOrgQuery, payload);

            case 4:
              subAccountDetail = _context4.sent;
              return _context4.abrupt("return", getResponse(subAccountDetail));

            case 6:
            case "end":
              return _context4.stop();
          }
        }
      }, fetchDetail);
    }),
    // 更新账号信息
    updateOne: /*#__PURE__*/_regeneratorRuntime.mark(function updateOne(_ref8, _ref9) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function updateOne$(_context5) {
        while (1) {
          switch (_context5.prev = _context5.next) {
            case 0:
              payload = _ref8.payload;
              call = _ref9.call;
              _context5.t0 = getResponse;
              _context5.next = 5;
              return call(subAccountOrgUpdateOne, payload);

            case 5:
              _context5.t1 = _context5.sent;
              res = (0, _context5.t0)(_context5.t1);
              return _context5.abrupt("return", res);

            case 8:
            case "end":
              return _context5.stop();
          }
        }
      }, updateOne);
    }),
    // 创建新的账号
    createOne: /*#__PURE__*/_regeneratorRuntime.mark(function createOne(_ref10, _ref11) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function createOne$(_context6) {
        while (1) {
          switch (_context6.prev = _context6.next) {
            case 0:
              payload = _ref10.payload;
              call = _ref11.call;
              _context6.t0 = getResponse;
              _context6.next = 5;
              return call(subAccountOrgCreateOne, payload);

            case 5:
              _context6.t1 = _context6.sent;
              res = (0, _context6.t0)(_context6.t1);
              return _context6.abrupt("return", res);

            case 8:
            case "end":
              return _context6.stop();
          }
        }
      }, createOne);
    }),
    // 当前登录用户所拥有的id
    roleQueryAll: /*#__PURE__*/_regeneratorRuntime.mark(function roleQueryAll(_ref12, _ref13) {
      var payload, call, put, res, createSubRoles;
      return _regeneratorRuntime.wrap(function roleQueryAll$(_context7) {
        while (1) {
          switch (_context7.prev = _context7.next) {
            case 0:
              payload = _ref12.payload;
              call = _ref13.call, put = _ref13.put;
              _context7.next = 4;
              return call(subAccountOrgRoleQueryAll, payload);

            case 4:
              res = _context7.sent;
              createSubRoles = getResponse(res);

              if (!res) {
                _context7.next = 9;
                break;
              }

              _context7.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  createSubRoles: createSubRoles
                }
              });

            case 9:
              return _context7.abrupt("return", createSubRoles);

            case 10:
            case "end":
              return _context7.stop();
          }
        }
      }, roleQueryAll);
    }),
    // 查询当前用户所拥有的角色
    roleCurrent: /*#__PURE__*/_regeneratorRuntime.mark(function roleCurrent(_ref14, _ref15) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function roleCurrent$(_context8) {
        while (1) {
          switch (_context8.prev = _context8.next) {
            case 0:
              payload = _ref14.payload;
              call = _ref15.call;
              _context8.next = 4;
              return call(subAccountOrgRoleCurrent, payload);

            case 4:
              res = _context8.sent;
              return _context8.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context8.stop();
          }
        }
      }, roleCurrent);
    }),
    // 获取快码
    fetchEnum: /*#__PURE__*/_regeneratorRuntime.mark(function fetchEnum(_, _ref16) {
      var call, put, res;
      return _regeneratorRuntime.wrap(function fetchEnum$(_context9) {
        while (1) {
          switch (_context9.prev = _context9.next) {
            case 0:
              call = _ref16.call, put = _ref16.put;
              _context9.t0 = getResponse;
              _context9.next = 4;
              return call(queryMapIdpValue, {
                level: 'CIAM.RESOURCE_LEVEL',
                authorityType: 'CIAM.AUTHORITY_TYPE_CODE',
                idd: 'CPFM.IDD',
                // 国际化手机号前缀
                gender: 'CPFM.GENDER',
                // 性别
                userType: 'CIAM.USER_TYPE'
              });

            case 4:
              _context9.t1 = _context9.sent;
              res = (0, _context9.t0)(_context9.t1);

              if (_isEmpty(res)) {
                _context9.next = 9;
                break;
              }

              _context9.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  enumMap: res
                }
              });

            case 9:
            case "end":
              return _context9.stop();
          }
        }
      }, fetchEnum);
    }),
    // 查询 组织
    queryUnitsTree: /*#__PURE__*/_regeneratorRuntime.mark(function queryUnitsTree(_ref17, _ref18) {
      var params, call, put, res, response;
      return _regeneratorRuntime.wrap(function queryUnitsTree$(_context10) {
        while (1) {
          switch (_context10.prev = _context10.next) {
            case 0:
              params = _ref17.payload.params;
              call = _ref18.call, put = _ref18.put;
              _context10.next = 4;
              return call(_queryUnitsTree, params);

            case 4:
              res = _context10.sent;
              response = getResponse(res);
              _context10.next = 8;
              return put({
                type: 'updateState',
                payload: {
                  unitsTree: !_isEmpty(response) ? response : []
                }
              });

            case 8:
            case "end":
              return _context10.stop();
          }
        }
      }, queryUnitsTree);
    }),
    // 打开修改密码
    openPassword: /*#__PURE__*/_regeneratorRuntime.mark(function openPassword(_ref19, _ref20) {
      var payload, put, userInfo;
      return _regeneratorRuntime.wrap(function openPassword$(_context11) {
        while (1) {
          switch (_context11.prev = _context11.next) {
            case 0:
              payload = _ref19.payload;
              put = _ref20.put;
              userInfo = payload.userInfo;
              _context11.next = 5;
              return put({
                type: 'updateState',
                payload: {
                  passwordProps: {
                    visible: true,
                    userInfo: userInfo
                  }
                }
              });

            case 5:
            case "end":
              return _context11.stop();
          }
        }
      }, openPassword);
    }),
    // 关闭修改密码
    closePassword: /*#__PURE__*/_regeneratorRuntime.mark(function closePassword(_, _ref21) {
      var put;
      return _regeneratorRuntime.wrap(function closePassword$(_context12) {
        while (1) {
          switch (_context12.prev = _context12.next) {
            case 0:
              put = _ref21.put;
              _context12.next = 3;
              return put({
                type: 'updateState',
                payload: {
                  passwordProps: {
                    visible: false,
                    userInfo: {}
                  }
                }
              });

            case 3:
            case "end":
              return _context12.stop();
          }
        }
      }, closePassword);
    }),
    // 更新密码
    updatePassword: /*#__PURE__*/_regeneratorRuntime.mark(function updatePassword(_ref22, _ref23) {
      var payload, call, id, userOrganizationId, antherPassword, params, res;
      return _regeneratorRuntime.wrap(function updatePassword$(_context13) {
        while (1) {
          switch (_context13.prev = _context13.next) {
            case 0:
              payload = _ref22.payload;
              call = _ref23.call;
              id = payload.id, userOrganizationId = payload.userOrganizationId, antherPassword = payload.antherPassword, params = _objectWithoutProperties(payload, _excluded);
              _context13.t0 = getResponse;
              _context13.next = 6;
              return call(subAccountOrgUpdatePassword, id, userOrganizationId, _objectSpread(_objectSpread({}, params), {}, {
                organizationId: userOrganizationId
              }));

            case 6:
              _context13.t1 = _context13.sent;
              res = (0, _context13.t0)(_context13.t1);
              return _context13.abrupt("return", res);

            case 9:
            case "end":
              return _context13.stop();
          }
        }
      }, updatePassword);
    }),
    // 解锁用户
    unlockUser: /*#__PURE__*/_regeneratorRuntime.mark(function unlockUser(_ref24, _ref25) {
      var payload, call, userId, organizationId, res;
      return _regeneratorRuntime.wrap(function unlockUser$(_context14) {
        while (1) {
          switch (_context14.prev = _context14.next) {
            case 0:
              payload = _ref24.payload;
              call = _ref25.call;
              userId = payload.userId, organizationId = payload.organizationId;
              _context14.t0 = getResponse;
              _context14.next = 6;
              return call(subAccountSiteUserUnlock, userId, organizationId);

            case 6:
              _context14.t1 = _context14.sent;
              res = (0, _context14.t0)(_context14.t1);
              return _context14.abrupt("return", res);

            case 9:
            case "end":
              return _context14.stop();
          }
        }
      }, unlockUser);
    }),
    // 删除角色
    deleteRoles: /*#__PURE__*/_regeneratorRuntime.mark(function deleteRoles(_ref26, _ref27) {
      var payload, call, memberRoleList, res;
      return _regeneratorRuntime.wrap(function deleteRoles$(_context15) {
        while (1) {
          switch (_context15.prev = _context15.next) {
            case 0:
              payload = _ref26.payload;
              call = _ref27.call;
              memberRoleList = payload.memberRoleList;
              _context15.t0 = getResponse;
              _context15.next = 6;
              return call(_deleteRoles, memberRoleList);

            case 6:
              _context15.t1 = _context15.sent;
              res = (0, _context15.t0)(_context15.t1);
              return _context15.abrupt("return", res);

            case 9:
            case "end":
              return _context15.stop();
          }
        }
      }, deleteRoles);
    }),
    // 查询 当前用户 已分配的用户组
    getCurrentUserGroups: /*#__PURE__*/_regeneratorRuntime.mark(function getCurrentUserGroups(_ref28, _ref29) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function getCurrentUserGroups$(_context16) {
        while (1) {
          switch (_context16.prev = _context16.next) {
            case 0:
              payload = _ref28.payload;
              call = _ref29.call;
              _context16.next = 4;
              return call(subAccountOrgGroupCurrent, payload);

            case 4:
              res = _context16.sent;
              return _context16.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context16.stop();
          }
        }
      }, getCurrentUserGroups);
    }),
    // 查询当前租户可分配的用户组
    fetchGroups: /*#__PURE__*/_regeneratorRuntime.mark(function fetchGroups(_ref30, _ref31) {
      var payload, call, rolesRes;
      return _regeneratorRuntime.wrap(function fetchGroups$(_context17) {
        while (1) {
          switch (_context17.prev = _context17.next) {
            case 0:
              payload = _ref30.payload;
              call = _ref31.call;
              _context17.next = 4;
              return call(subAccountOrgGroupQueryAll, payload);

            case 4:
              rolesRes = _context17.sent;
              return _context17.abrupt("return", getResponse(rolesRes));

            case 6:
            case "end":
              return _context17.stop();
          }
        }
      }, fetchGroups);
    }),
    // 添加用户组
    addUserGroup: /*#__PURE__*/_regeneratorRuntime.mark(function addUserGroup(_ref32, _ref33) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function addUserGroup$(_context18) {
        while (1) {
          switch (_context18.prev = _context18.next) {
            case 0:
              payload = _ref32.payload;
              call = _ref33.call;
              _context18.next = 4;
              return call(_addUserGroup, payload);

            case 4:
              res = _context18.sent;
              return _context18.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context18.stop();
          }
        }
      }, addUserGroup);
    }),
    // 删除用户组
    deleteUserGroup: /*#__PURE__*/_regeneratorRuntime.mark(function deleteUserGroup(_ref34, _ref35) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function deleteUserGroup$(_context19) {
        while (1) {
          switch (_context19.prev = _context19.next) {
            case 0:
              payload = _ref34.payload;
              call = _ref35.call;
              _context19.next = 4;
              return call(_deleteUserGroup, payload);

            case 4:
              res = _context19.sent;
              return _context19.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context19.stop();
          }
        }
      }, deleteUserGroup);
    }),

    /* 接口字段权限维护 */
    // 初始化 接口查询 值集 等 初始化 数据
    apiInit: /*#__PURE__*/_regeneratorRuntime.mark(function apiInit(_, _ref36) {
      var call, put, res, requestMethod;
      return _regeneratorRuntime.wrap(function apiInit$(_context20) {
        while (1) {
          switch (_context20.prev = _context20.next) {
            case 0:
              call = _ref36.call, put = _ref36.put;
              _context20.next = 3;
              return call(queryUnifyIdpValue, 'CIAM.REQUEST_METHOD');

            case 3:
              res = _context20.sent;
              requestMethod = getResponse(res);

              if (!requestMethod) {
                _context20.next = 8;
                break;
              }

              _context20.next = 8;
              return put({
                type: 'updateState',
                payload: {
                  requestMethod: requestMethod
                }
              });

            case 8:
            case "end":
              return _context20.stop();
          }
        }
      }, apiInit);
    }),
    // 查询接口
    queryApis: /*#__PURE__*/_regeneratorRuntime.mark(function queryApis(_ref37, _ref38) {
      var payload, call, put, params, res, apis;
      return _regeneratorRuntime.wrap(function queryApis$(_context21) {
        while (1) {
          switch (_context21.prev = _context21.next) {
            case 0:
              payload = _ref37.payload;
              call = _ref38.call, put = _ref38.put;
              params = payload.params;
              _context21.next = 5;
              return call(apiFieldApiQuery, params);

            case 5:
              res = _context21.sent;
              apis = getResponse(res);

              if (!apis) {
                _context21.next = 10;
                break;
              }

              _context21.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  apiDataSource: apis.content,
                  apiPagination: createPagination(apis)
                }
              });

            case 10:
            case "end":
              return _context21.stop();
          }
        }
      }, queryApis);
    }),
    // 初始化 接口查询 值集 等 初始化 数据
    fieldPermissionInit: /*#__PURE__*/_regeneratorRuntime.mark(function fieldPermissionInit(_, _ref39) {
      var call, put, res, enums;
      return _regeneratorRuntime.wrap(function fieldPermissionInit$(_context22) {
        while (1) {
          switch (_context22.prev = _context22.next) {
            case 0:
              call = _ref39.call, put = _ref39.put;
              _context22.next = 3;
              return call(queryMapIdpValue, {
                fieldType: 'CIAM.FIELD.TYPE',
                permissionRule: 'CIAM.FIELD.PERMISSION_TYPE'
              });

            case 3:
              res = _context22.sent;
              enums = getResponse(res);

              if (!enums) {
                _context22.next = 8;
                break;
              }

              _context22.next = 8;
              return put({
                type: 'updateState',
                payload: enums
              });

            case 8:
            case "end":
              return _context22.stop();
          }
        }
      }, fieldPermissionInit);
    }),
    // 查询接口对应字段权限
    queryFieldPermissions: /*#__PURE__*/_regeneratorRuntime.mark(function queryFieldPermissions(_ref40, _ref41) {
      var payload, call, put, userId, permissionId, params, res, fieldPermissions;
      return _regeneratorRuntime.wrap(function queryFieldPermissions$(_context23) {
        while (1) {
          switch (_context23.prev = _context23.next) {
            case 0:
              payload = _ref40.payload;
              call = _ref41.call, put = _ref41.put;
              userId = payload.userId, permissionId = payload.permissionId, params = payload.params;
              _context23.next = 5;
              return call(apiFieldFieldPermissionQuery, userId, permissionId, params);

            case 5:
              res = _context23.sent;
              fieldPermissions = getResponse(res);

              if (!fieldPermissions) {
                _context23.next = 10;
                break;
              }

              _context23.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  fieldPermissionDataSource: fieldPermissions.content,
                  fieldPermissionPagination: createPagination(fieldPermissions)
                }
              });

            case 10:
            case "end":
              return _context23.stop();
          }
        }
      }, queryFieldPermissions);
    }),
    // 更新接口对应字段权限
    updateFieldPermission: /*#__PURE__*/_regeneratorRuntime.mark(function updateFieldPermission(_ref42, _ref43) {
      var payload, call, userId, permissionId, record, res;
      return _regeneratorRuntime.wrap(function updateFieldPermission$(_context24) {
        while (1) {
          switch (_context24.prev = _context24.next) {
            case 0:
              payload = _ref42.payload;
              call = _ref43.call;
              userId = payload.userId, permissionId = payload.permissionId, record = payload.record;
              _context24.next = 5;
              return call(apiFieldFieldPermissionUpdate, userId, permissionId, record);

            case 5:
              res = _context24.sent;
              return _context24.abrupt("return", getResponse(res));

            case 7:
            case "end":
              return _context24.stop();
          }
        }
      }, updateFieldPermission);
    }),
    // 新增接口对应字段权限
    createFieldPermission: /*#__PURE__*/_regeneratorRuntime.mark(function createFieldPermission(_ref44, _ref45) {
      var payload, call, userId, permissionId, record, res;
      return _regeneratorRuntime.wrap(function createFieldPermission$(_context25) {
        while (1) {
          switch (_context25.prev = _context25.next) {
            case 0:
              payload = _ref44.payload;
              call = _ref45.call;
              userId = payload.userId, permissionId = payload.permissionId, record = payload.record;
              _context25.next = 5;
              return call(apiFieldFieldPermissionCreate, userId, permissionId, record);

            case 5:
              res = _context25.sent;
              return _context25.abrupt("return", getResponse(res));

            case 7:
            case "end":
              return _context25.stop();
          }
        }
      }, createFieldPermission);
    }),
    // 删除接口对应字段权限
    removeFieldPermission: /*#__PURE__*/_regeneratorRuntime.mark(function removeFieldPermission(_ref46, _ref47) {
      var payload, call, permissionId, record, res;
      return _regeneratorRuntime.wrap(function removeFieldPermission$(_context26) {
        while (1) {
          switch (_context26.prev = _context26.next) {
            case 0:
              payload = _ref46.payload;
              call = _ref47.call;
              permissionId = payload.permissionId, record = payload.record;
              _context26.next = 5;
              return call(apiFieldFieldPermissionRemove, permissionId, record);

            case 5:
              res = _context26.sent;
              return _context26.abrupt("return", getResponse(res));

            case 7:
            case "end":
              return _context26.stop();
          }
        }
      }, removeFieldPermission);
    }),
    // 查询角色已分配的安全组
    querySecurityGroup: /*#__PURE__*/_regeneratorRuntime.mark(function querySecurityGroup(_ref48, _ref49) {
      var payload, call, put, res, list;
      return _regeneratorRuntime.wrap(function querySecurityGroup$(_context27) {
        while (1) {
          switch (_context27.prev = _context27.next) {
            case 0:
              payload = _ref48.payload;
              call = _ref49.call, put = _ref49.put;
              _context27.next = 4;
              return call(_querySecurityGroup, payload);

            case 4:
              res = _context27.sent;
              list = getResponse(res);

              if (!list) {
                _context27.next = 9;
                break;
              }

              _context27.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  secGrpList: list.content,
                  secGrpPagination: createPagination(list)
                }
              });

            case 9:
            case "end":
              return _context27.stop();
          }
        }
      }, querySecurityGroup);
    }),
    // 角色分配安全组
    assignSecGrp: /*#__PURE__*/_regeneratorRuntime.mark(function assignSecGrp(_ref50, _ref51) {
      var secGrpList, roleId, call, res;
      return _regeneratorRuntime.wrap(function assignSecGrp$(_context28) {
        while (1) {
          switch (_context28.prev = _context28.next) {
            case 0:
              secGrpList = _ref50.secGrpList, roleId = _ref50.roleId;
              call = _ref51.call;
              _context28.next = 4;
              return call(_assignSecGrp, secGrpList, roleId);

            case 4:
              res = _context28.sent;
              return _context28.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context28.stop();
          }
        }
      }, assignSecGrp);
    }),
    // 批量删除安全组
    deleteSecGrp: /*#__PURE__*/_regeneratorRuntime.mark(function deleteSecGrp(_ref52, _ref53) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function deleteSecGrp$(_context29) {
        while (1) {
          switch (_context29.prev = _context29.next) {
            case 0:
              payload = _ref52.payload;
              call = _ref53.call;
              _context29.next = 4;
              return call(_deleteSecGrp, payload);

            case 4:
              res = _context29.sent;
              return _context29.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context29.stop();
          }
        }
      }, deleteSecGrp);
    }),
    // 查询角色已分配的指定安全组的字段权限
    queryFieldPermission: /*#__PURE__*/_regeneratorRuntime.mark(function queryFieldPermission(_ref54, _ref55) {
      var payload, call, put, res, list;
      return _regeneratorRuntime.wrap(function queryFieldPermission$(_context30) {
        while (1) {
          switch (_context30.prev = _context30.next) {
            case 0:
              payload = _ref54.payload;
              call = _ref55.call, put = _ref55.put;
              _context30.next = 4;
              return call(_queryFieldPermission, payload);

            case 4:
              res = _context30.sent;
              list = getResponse(res);

              if (!list) {
                _context30.next = 9;
                break;
              }

              _context30.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  secGrpFieldPermissionList: list.content,
                  secGrpFieldPermissionPagination: createPagination(list)
                }
              });

            case 9:
            case "end":
              return _context30.stop();
          }
        }
      }, queryFieldPermission);
    }),
    // 查询角色已分配的指定安全组的字段权限
    queryFieldConfig: /*#__PURE__*/_regeneratorRuntime.mark(function queryFieldConfig(_ref56, _ref57) {
      var payload, call, res, list;
      return _regeneratorRuntime.wrap(function queryFieldConfig$(_context31) {
        while (1) {
          switch (_context31.prev = _context31.next) {
            case 0:
              payload = _ref56.payload;
              call = _ref57.call;
              _context31.next = 4;
              return call(_queryFieldConfig, payload);

            case 4:
              res = _context31.sent;
              list = getResponse(res);
              return _context31.abrupt("return", {
                dataSource: list ? list.content : [],
                pagination: list ? createPagination(list) : {}
              });

            case 7:
            case "end":
              return _context31.stop();
          }
        }
      }, queryFieldConfig);
    }),
    // 查询角色已分配的指定安全组的数据权限维度
    queryDataDimension: /*#__PURE__*/_regeneratorRuntime.mark(function queryDataDimension(_ref58, _ref59) {
      var payload, call, put, res, list;
      return _regeneratorRuntime.wrap(function queryDataDimension$(_context32) {
        while (1) {
          switch (_context32.prev = _context32.next) {
            case 0:
              payload = _ref58.payload;
              call = _ref59.call, put = _ref59.put;
              _context32.next = 4;
              return call(_queryDataDimension, payload);

            case 4:
              res = _context32.sent;
              list = getResponse(res);

              if (!list) {
                _context32.next = 9;
                break;
              }

              _context32.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  secGrpDimensionList: list.content,
                  secGrpDimensionPagination: createPagination(list)
                }
              });

            case 9:
            case "end":
              return _context32.stop();
          }
        }
      }, queryDataDimension);
    }),
    // 查询安全组数据权限tab页
    queryDataPermissionTab: /*#__PURE__*/_regeneratorRuntime.mark(function queryDataPermissionTab(_ref60, _ref61) {
      var secGrpId, call, put, res, list;
      return _regeneratorRuntime.wrap(function queryDataPermissionTab$(_context33) {
        while (1) {
          switch (_context33.prev = _context33.next) {
            case 0:
              secGrpId = _ref60.secGrpId;
              call = _ref61.call, put = _ref61.put;
              _context33.next = 4;
              return call(queryTabList, secGrpId);

            case 4:
              res = _context33.sent;
              list = getResponse(res);

              if (!list) {
                _context33.next = 9;
                break;
              }

              _context33.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  secGrpDataPermissionTabList: list
                }
              });

            case 9:
            case "end":
              return _context33.stop();
          }
        }
      }, queryDataPermissionTab);
    }),
    // 查询可分配的安全组
    fetchAssignableSecGrp: /*#__PURE__*/_regeneratorRuntime.mark(function fetchAssignableSecGrp(_ref62, _ref63) {
      var payload, call, put, res, list;
      return _regeneratorRuntime.wrap(function fetchAssignableSecGrp$(_context34) {
        while (1) {
          switch (_context34.prev = _context34.next) {
            case 0:
              payload = _ref62.payload;
              call = _ref63.call, put = _ref63.put;
              _context34.next = 4;
              return call(queryAssignableSecGrp, payload);

            case 4:
              res = _context34.sent;
              list = getResponse(res);

              if (!list) {
                _context34.next = 9;
                break;
              }

              _context34.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  secGrpAddModalList: list.content,
                  secGrpAddModalPagination: createPagination(list)
                }
              });

            case 9:
            case "end":
              return _context34.stop();
          }
        }
      }, fetchAssignableSecGrp);
    }),
    queryDimension: /*#__PURE__*/_regeneratorRuntime.mark(function queryDimension(_ref64, _ref65) {
      var payload, call, put, res;
      return _regeneratorRuntime.wrap(function queryDimension$(_context35) {
        while (1) {
          switch (_context35.prev = _context35.next) {
            case 0:
              payload = _ref64.payload;
              call = _ref65.call, put = _ref65.put;
              _context35.t0 = getResponse;
              _context35.next = 5;
              return call(_queryDimension, payload);

            case 5:
              _context35.t1 = _context35.sent;
              res = (0, _context35.t0)(_context35.t1);

              if (!res) {
                _context35.next = 10;
                break;
              }

              _context35.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  dimensionList: res
                }
              });

            case 10:
              return _context35.abrupt("return", res);

            case 11:
            case "end":
              return _context35.stop();
          }
        }
      }, queryDimension);
    }),
    queryEmployee: /*#__PURE__*/_regeneratorRuntime.mark(function queryEmployee(_ref66, _ref67) {
      var payload, call, put, res, employeeList;
      return _regeneratorRuntime.wrap(function queryEmployee$(_context36) {
        while (1) {
          switch (_context36.prev = _context36.next) {
            case 0:
              payload = _ref66.payload;
              call = _ref67.call, put = _ref67.put;
              _context36.next = 4;
              return call(_queryEmployee, payload);

            case 4:
              res = _context36.sent;
              employeeList = getResponse(res);

              if (!employeeList) {
                _context36.next = 9;
                break;
              }

              _context36.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  employeeList: employeeList.content,
                  employeePagination: createPagination(employeeList)
                }
              });

            case 9:
            case "end":
              return _context36.stop();
          }
        }
      }, queryEmployee);
    })
  },
  reducers: {
    updateState: function updateState(state, _ref68) {
      var payload = _ref68.payload;
      return _objectSpread(_objectSpread({}, state), payload);
    }
  }
};